Socket
Socket
Sign inDemoInstall

atomic-file-rw

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atomic-file-rw

This module is meant as a replacement for [atomic-file](https://github.com/flumedb/atomic-file) as it has better error handling on node and is faster in the browser.


Version published
Maintainers
1
Created
Source

Atomic-file-rw

This module is meant as a replacement for atomic-file as it has better error handling on node and is faster in the browser.

The library is written to handle writing to a few number of files in a safe manner. Concurrent writes to the same file are completed in the order they are started. A temporary file with the same filename as the original — with a suffix ~ — is employed to ensure atomicity.

Example

Write a buffer to file and read it again:

const atomic = require('atomic-file-rw')

atomic.writeFile("test.txt", Buffer.from('GREETINGS'), (err, x) => {
  atomic.readFile("test.txt", (err, buf) => {
    console.log(buf.toString())
  })
})

API

atomic.readFile(path[, options], callback)

Same arguments as Node.js's fs.readFile, but in the browser the options is ignored.

atomic.writeFile(file, data[, options], callback)

Same arguments as Node.js's fs.writeFile, but in the browser the options is ignored.

FAQs

Package last updated on 01 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc